package com.my.chapter21;

public class practice8 {
    public static void main(String[] args) {
        for(int i = 0; i < 5; i++) {
            Thread t = new Thread(new LiftOff2());
            t.setDaemon(true);
            t.start();
        }
        System.out.println("Waiting for LiftOff");
    }
}

class LiftOff2 implements Runnable{
    protected int countDown = 5;
    private static int taskCount = 0;
    private static  int id = taskCount++;
    public LiftOff2(){}
    public LiftOff2(int countDown){ this.countDown = countDown; }
    public String status(){
        return "#" + id + "(" +
                (countDown>0 ? countDown : "LiftOff!") + ").";
    }
    @Override
    public void run() {
        while (countDown-- >0){
            System.out.println(status());
            Thread.yield();
        }
    }
}
